package cn.flying.base.core.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ModelAttribute;

import cn.flying.base.common.utils.StringUtils;
import cn.flying.base.common.vo.PageParam;

/**
 * @description:
 * @author: lvyong
 * @date: 2023年02月20日 18:10
 * @version: 1.0
 */
public class BaseController {

    protected PageParam pageParam = new PageParam();

    private static final String PAGE_NUM = "pageNum";
    private static final String PAGE_SIZE = "pageSize";

    @ModelAttribute
    public void setParam(HttpServletRequest request) {
        if (StringUtils.isNotBlank(request.getParameter(PAGE_NUM))) {
            pageParam.setPageNum(Integer.valueOf(request.getParameter(PAGE_NUM)));
        }
        if (StringUtils.isNotBlank(request.getParameter(PAGE_SIZE))) {
            pageParam.setPageSize(Integer.valueOf(request.getParameter(PAGE_SIZE)));
        }
    }
}
